<?php
include ("../../../include/functions.inc.php");

if (getParam("op") == "getDiplo") {

    $value = getParam("carnet");
    $pieces = explode(" - ", $value);
    $carnet = $pieces[0];
    $ciclo = getParam("cycle");

    $diplo = $db->queryToArray("SELECT cllg_student_assign.ID AS id, cllg_career.NAME 
                                FROM cllg_student_assign,cllg_career 
                                WHERE cllg_student_assign.FK_STUDENT = '{$carnet}' 
                                AND cllg_student_assign.FK_CYCLE = '{$ciclo}' 
                                AND cllg_student_assign.FK_CAREER = cllg_career.ID 
                                AND cllg_student_assign.STATUS!=0");
    if (count($diplo) == 0) {
        echo "<td colspan='2'><h5 style='blue'>No se encontraron diplomados asignado a este alumno</h5><td>";
    } else {
        ?>
        <legend>Seleccione diplomado</legend>
        <table style="width: 500px" class="table table-bordered table-striped table-hover">
            <?php
            foreach ($diplo as $d) {
                ?>
                <tr>
                    <td width="70%"><?php echo $d['NAME']; ?></td>
                    <td width="30%"><input type="button" class="btn btn-info" value="Cargar Certificación" onclick="getCert(<?php echo $d['id']; ?>);"/></td>
                </tr>    
                <?php
            }
            ?>
        </table>
        <?php
    }
} elseif (getParam("op") == "getName") {

    $stud = $db->query_select("cllg_student", sprintf("ID=%s", getParam("carnet")));
    if (count($stud) == 0) {
        echo "<td colspan='2'><h5 style='color:blue'>No hay ningún estudiante con ese carnet</h5></td>";
    } else {
        ?>
        <td>
            <label for="fullName">NOMBRE</label>
        </td>
        <td>
            <input type="text" readonly="readonly" value="<?php echo $stud[0]['FIRST_NAME'] . " " . $stud[0]["LAST_NAME"]; ?>"/>
        </td>
        <?php
    }
}
?>
